package com.example.repository;

import com.example.entity.Label;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface LabelRepository {
    //多对多子查询
    @Results(id = "label",value = {
            @Result(property = "id",column = "id",jdbcType = JdbcType.INTEGER,id = true),
            @Result(property = "labelName",column = "label_name",jdbcType = JdbcType.VARCHAR)
    })
    @Select("SELECT * FROM label l,label_article la,article a \n" +
            "WHERE la.article_id = a.id AND la.`label_id`=l.`id` AND la.article_id = #{lid}")
    public List<Label> findByLId(int lid);


}
